package com.googlecode.mylyn.ui.editor;

import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.ui.editors.AbstractAttributeEditor;
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
import org.eclipse.mylyn.tasks.ui.editors.AttributeEditorFactory;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;

import com.googlecode.mylyn.core.GoogleCodeCorePlugin;
import com.googlecode.mylyn.core.IGoogleCodeConstants;

/**
 * This page allows the user to edit an Google Code task.
 */
class GoogleCodeTaskEditorPage extends AbstractTaskEditorPage {

    GoogleCodeTaskEditorPage(TaskEditor editor) {
        super(editor, "googleCodeTaskEditorPage", "Google Code", GoogleCodeCorePlugin.CONNECTOR_KIND);
        setNeedsPrivateSection(false);
        setNeedsSubmitButton(true);
    }
    
    @Override
    protected AttributeEditorFactory createAttributeEditorFactory() {
        AttributeEditorFactory factory = new AttributeEditorFactory(getModel(), getTaskRepository(), getEditorSite()) {
            @Override
            public AbstractAttributeEditor createEditor(String type, final TaskAttribute taskAttribute) {
                AbstractAttributeEditor editor;
                if (IGoogleCodeConstants.EDITOR_TYPE_STARS.equals(type)) {
                    editor = new StarsAttributeEditor(getModel(), taskAttribute);
                } else {
                    editor = super.createEditor(type, taskAttribute);
                }
                return editor;
            }
        };
        return factory;
    }    

}
